//
//  PopView.m
//  zt_im
//
//  Created by icholab on 2022/10/19.
//

#import "PopView.h"
#import "TTActionSheetView.h"
#import "UIView+TUILayout.h"
#import "ZTDefine.h"

@implementation PopView

+ (void)showSheetWithTitle:(nullable NSString *)title message:(nullable NSString *)message cancel:(nullable NSString *)cancel actionStrs:(NSArray *)actionStrs WithController:(UIViewController *)viewController WithBlock:(nullable void (^)(NSInteger index,NSString *title))block{
    NSMutableArray *array = [NSMutableArray array];
   __block TTActionSheetView *alertView;
    for (NSString *title in actionStrs) {
        TTActionSheetConfig *config = [[TTActionSheetConfig alloc] init];
        config.title = title;
        config.titleColor = UIColorFromRGB(0xC6C6C6);
        config.clickAction = ^(TTActionSheetConfig * config) {
            block(0,config.title);
            [alertView removeFromSuperview];
        };
        [array addObject:config];
        
    }
//    UIView *view  = [UIApplication sharedApplication].keyWindow;
     alertView = [[TTActionSheetView alloc] initWithFrame:viewController.view.bounds needCancel:YES items:array];
    alertView.backgroundColor = UIColorRGBAlpha(0x000000, 0.8);
    alertView.cancelAction = ^{
        [UIView animateWithDuration:0.3 animations:^{
            alertView.mm_y = viewController.view.mm_y;
            [alertView removeFromSuperview];
        }];
    };
    [viewController.view addSubview:alertView];
    alertView.mm_y = viewController.view.mm_y;
    [UIView animateWithDuration:0.3 animations:^{
        alertView.mm_y = viewController.view.mm_b;
    }];
}

+ (void)showSheetWithTitle:(nullable NSString *)title message:(nullable NSString *)message cancel:(nullable NSString *)cancel actionStrs:(NSArray *)actionStrs WithController:(UIViewController *)viewController configure:(TTActionSheetConfig *)configure WithBlock:(nullable void (^)(NSInteger index,NSString *title))block{
}
@end
